//
//  FirCirNewsMailDataSource.m
//  tcpoctest
//
//  Created by apple on 13-5-2.
//  Copyright (c) 2013年 gump. All rights reserved.
//

#import "FirCirNewsMailDataSource.h"

@implementation FirCirNewsMailDataSource

-(id)init
{
    self = [super init];
    if (self != nil) {
        newsmailDic = [[NSMutableDictionary alloc] init];
        pthread_mutex_init(&newmailmutex, 0);
    }
    
    return self;
}

-(void)AddMail:(NSString *)mail withNewsID:(NSString *)newsid
{
    pthread_mutex_lock(&newmailmutex);
    
    [newsmailDic setObject:mail forKey:newsid];
    
    pthread_mutex_unlock(&newmailmutex);
}

-(NSString *)GetMailByNewsID:(NSString *)newsid
{
    NSString *mail = @"";
    
    pthread_mutex_lock(&newmailmutex);
    
    mail = [newsmailDic objectForKey:newsid];
    
    pthread_mutex_unlock(&newmailmutex);
    
    return mail;
}

-(void)DelByNewsID:(NSString *)newsid
{
    pthread_mutex_lock(&newmailmutex);
    
    [newsmailDic removeObjectForKey:newsid];
    
    pthread_mutex_unlock(&newmailmutex);
}

-(void)DelAll
{
    pthread_mutex_lock(&newmailmutex);
    
    [newsmailDic removeAllObjects];
    
    pthread_mutex_unlock(&newmailmutex);
}

@end
